<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="com.kamikaze.Member"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/sql"  prefix="sql" %>
<jsp:useBean id="clock" class="com.kamikaze.Clock" scope="session" />
<jsp:useBean id="member" class="com.kamikaze.Member" scope="session" />
<script src="nowtime.js" type="text/javascript"></script>
<%
	if (!member.login()) {
		out.print("<h1>請先登入</h1>");
		response.setHeader("refresh", "2;url=index.jsp");
	} else {
%>
<sql:query var="rs" dataSource="jdbc/j2db">
	select * 
	from shift, worktypes 
	where user_id = ?
	<sql:param>${member.user_id }</sql:param> 
	and shift_date = curdate() 
	and shift.wt_number = worktypes.wt_number
</sql:query>
<br><br>

<table>
<caption><h1>網頁打卡</h1></caption>
<hr>
<tr><td>員工編號：</td><td>${member.user_id }</td></tr>
<c:forEach var="r" items="${rs.rows }">
	<tr><td>今日班別：</td><td><c:out value="${r.wt_name }" /></td></tr>
	<tr><td>上班時間：</td><td><c:out value="${r.on_time }" /></td></tr>
	<tr><td>下班時間：</td><td><c:out value="${r.off_time }" /></td></tr>
</c:forEach>
</table>
<br><br>
<span id="Y"></span>
<span id="MH"></span>
<span id="TD"></span>
<span id="D"></span>
<span id="APM"></span>
<span id="H"></span>
<span id="M"></span>
<span id="S"></span>
<br><br>
<form action="clock" method="post">
	<select name="clock_type">
		<option value="1">上班
		<option value="2">下班
	</select> <input type="hidden" name="user_id" value="${member.user_id }" /> <input
		type="submit" value="打卡" />
</form>
<br><br>
<%
	for (String msg : clock.getMsg()) {
%><h1><%=msg%></h1>
<%
	}
}
%>